/*
 * CONVERT DIALOG TITLE TO HTML
 * REF: http://stackoverflow.com/questions/14488774/using-html-in-a-dialogs-title-in-jquery-ui-1-10
 */
$.widget("ui.dialog", $.extend({}, $.ui.dialog.prototype, {
	_title: function(title) {
		if (!this.options.title) {
			title.html("&#160;");
		} else {
			title.html(this.options.title);
		}
	}
}));
var VSurvey = Backbone.View.extend({
	initialize: function() {
		this.setElement("body");
		this.first = true;
		this.refresh();
	},

	events: {
		"click .btn-add": "addUser",
		"click .btn-save": "saveUser",
		"click .btn-remove": "removeUser",
		"click .btn-delete": "deleteUser",
		"click .btn-edit": "editUser",
		"click .btn-update": "updateUser",
		"click .btn-view": "viewUser",
		"click .btn-changepwd": "changepwd",
		"click .btn-unlockphone": "unlock",
		"click .btn-viewlocation": "location",
		//"click .btn-userface": "userface"
	},

	render: function(data) {
		console.log(data);
		var list = data.list;
		var page = data.page;
		html = "";
		for (var i = 0, len = list.length; i < len; i++) {
			html += template("user_listitem", list[i]);
		}
		$("#survey-list").html(html);

		if (this.first) {
			this.first = false;
			$(".pagination").jqPagination({
				max_page: page.pagesum,
				paged: function(page) {
					APPUSER.refresh(page);
				}
			});
		}
	}
});